Skip to content

fix(couchdb): create the doc when a concurrent request created its database - #5310

Closed
paultranvan wants to merge 1 commit into
masterfrom
fix/couchdb-upsert-db-creation-race
Closed

paultranvan wants to merge 1 commit into
masterfrom
fix/couchdb-upsert-db-creation-race

Conversation

@paultranvan

Copy link
Copy Markdown
Contributor

Summary

  • couchdb.Upsert and CreateNamedDocWithDB create the database of a doctype on its first document. When two requests race on it, the one that loses gets file_exists from CreateDB and returns it, while the database it needs exists. They now create the document anyway, as createDocOrDB already does.
  • Seen on the rag indexer e2e (linagora/rag-indexer): two POST /ai/index/status arriving together for the first io.cozy.ai.chat.rag docs of an instance, one answered 500 and its status was lost.
  • Test: TestUpsertLosingDatabaseCreationRace, with a fake CouchDB that answers file_exists on the database creation.

…tabase

Upsert and CreateNamedDocWithDB create the database of a doctype on its first document. When two requests race on it, the one that loses gets file_exists from CreateDB and failed, while the database it needs is there. They now go on and create the document, as createDocOrDB does.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant